package com.example.njupt.helper;

import android.net.Uri;

import androidx.core.app.ActivityOptionsCompat;

import com.alibaba.android.arouter.facade.Postcard;
import com.alibaba.android.arouter.launcher.ARouter;
import com.example.njupt.R;
import com.example.njupt.base.BaseApplication;

/**
 * Author:      mwang
 * Create Date: Created in 2021/4/25 11:13
 * Update Date:
 * Modified By:
 * Description:
 */
public class ARouteUtils {

    public static ActivityOptionsCompat initTransition() {
        return ActivityOptionsCompat.makeCustomAnimation(BaseApplication.getInstance()
                , R.anim.anim_in_inpage,
                R.anim.anim_in_outpage);
    }

    /**
    * 用于链接跳转
    * */
    public static void ARouteWithUrl(String url) {
        if (url != null) {
            ARouter.getInstance()
                    .build(Uri.parse(url))
                    .withOptionsCompat(initTransition())
                    .navigation();
        }
    }

    /**
    * 动画跳转ARoute包装
    * */
    public static Postcard routerWithAnimation(String path) {
        return ARouter.getInstance()
                .build(path)
                .withOptionsCompat(initTransition());
    }
}
